using Godot;
using System;

public partial class 去碰撞检测1 : Area2D
{
    public float speed = 200f;

    public override void _Ready()
    {
        AreaEntered += areaEntered;
        AreaExited += areaExited;
    }
    public override void _PhysicsProcess(double delta)
    {
        // 处理物理逻辑
        float f = Input.GetAxis("左", "右");
        if (f < 0)
        {
            Position += new Vector2(-speed * (float)delta, 0);
        }

        if (f > 0)
        {
            Position += new Vector2(speed * (float)delta, 0);
        }
    }


    public void areaEntered(Area2D area)
    {
        GD.Print($"Area  {area.Name} Entered into {Name}");
    }

    public void areaExited(Area2D area)
    {
        GD.Print($"Area  {area.Name} Exited from {Name}");
    }
}
